package com.lee.auth.security.context;

/**
 * @author Lee HN
 * @date 2021/3/31 16:32
 */
public final class AuthContextHolder {

    private static final ThreadLocal<AuthContext> ContextHolder = new ThreadLocal<>();

    public static AuthContext getAuthContext() {
        AuthContext context = ContextHolder.get();
        return context == null ? AuthContext.ANONYMOUS : context;
    }

    public static void setAuthContext(AuthContext context) {
        ContextHolder.set(context);
    }

    public static void clearAuthContext() {
        ContextHolder.remove();
    }

}
